<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - Bootstrap3 表单构建器</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="../../static/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="../../static/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="../../static/css/animate.css" rel="stylesheet">
    <link href="../../static/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="../../static/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
    <link href="../../static/css/style.css?v=4.0.0" rel="stylesheet">
    <!-- Sweet Alert -->
    <link href="../../static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <base target="_blank">

    <link href="../../static/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="../../static/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
    <link href="../../static/css/style.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <link href="../../static/css/plugins/footable/footable.core.css" rel="stylesheet">
    <script src="../../static/js/commonrequest.js"></script>


    <style>
        .droppable-active {
            background-color: #ffe !important
        }

        .tools a {
            cursor: pointer;
            font-size: 80%
        }

        .form-body .col-md-6, .form-body .col-md-12 {
            min-height: 400px
        }

        .draggable {
            cursor: move
        }
    </style>

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-5">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>设置接口</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_editors.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form role="form" class="form-horizontal m-t" id="inputForm" target="_self">
                        <div class="clearfix"></div>
                        <div class="form-group ">
                            <label class="col-sm-3 control-label">接口名称：</label>
                            <div class="col-sm-9">
                                <p class="form-control-static">患者信息取数接口</p>
                            </div>
                        </div>
                        <div class="form-group ">
                            <label class="col-sm-3 control-label">推送方式：</label>
                            <div class="col-sm-9">
                                <p class="form-control-static">POST</p>
                            </div>
                        </div>
                        <div class="form-group ">
                            <label class="col-sm-3 control-label">请求参数：</label>
                            <div class="col-sm-3">
                                <select id="option" class="form-control" name="option">
                                    <option value="updateDateTime">查询日期</option>
                                    <option value="pathNo">病历号</option>
                                </select>
                            </div>
                            <label id="submitName" hidden></label>
                            <div class="col-sm-4">
                                <input type="text" id="searchText" value="" name="searchText" class="form-control"
                                       required="" placeholder="样式：2020-02-03">
                                <span class="help-block m-b-none"></span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-5 col-sm-offset-3">
                                <button class="btn btn-primary" id="submit1">提交</button>
                                <button class="btn btn-primary" id="submitSave">提交(保存)</button>
                                <button class="btn btn-white" id="clear1">清空</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>接口请求详细</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_editors.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="form-group ">
                        <div class="col-sm-12 col-sm-offset-4">
                            <button class="btn btn-white" id="clear2" type="submit">清空</button>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                    <div class="row m-t-lg">
                        <div class="col-lg-12">
                            <small>请求json</small>
                            <pre id="toastrOptions" class="p-m"></pre>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-sm-7">
            <div class="ibox-content">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>接口返回信息</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="form_editors.html#">
                                <i class="fa fa-wrench"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="form-group ">
                            <div class="col-sm-12 col-sm-offset-4">
                                <button class="btn btn-white" id="clear3" type="submit">清空</button>
                            </div>
                        </div>
                        <div id="loading" style="text-align:center;line-height:22px;">
                            <div class="sk-spinner sk-spinner-fading-circle"
                                 style="margin-top: 50px;display:inline-block;">
                                <div class="sk-circle1 sk-circle"></div>
                                <div class="sk-circle2 sk-circle"></div>
                                <div class="sk-circle3 sk-circle"></div>
                                <div class="sk-circle4 sk-circle"></div>
                                <div class="sk-circle5 sk-circle"></div>
                                <div class="sk-circle6 sk-circle"></div>
                                <div class="sk-circle7 sk-circle"></div>
                                <div class="sk-circle8 sk-circle"></div>
                                <div class="sk-circle9 sk-circle"></div>
                                <div class="sk-circle10 sk-circle"></div>
                                <div class="sk-circle11 sk-circle"></div>
                                <div class="sk-circle12 sk-circle"></div>
                            </div>
                            <div>
                                正在加载数据,请稍候...
                            </div>
                        </div>

                        <div class="clearfix"></div>
                        <div class="row m-t-lg">
                            <div class="col-lg-12">
                                <small>返回json</small>
                                <pre id="toastrOptions2" class="p-m"></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
<script src="../../static/js/jquery.min.js?v=2.1.4"></script>
<script src="../../static/js/bootstrap.min.js?v=3.3.5"></script>
<script src="../../static/js/content.min.js?v=1.0.0"></script>
<script src="../../static/js/jquery-ui-1.10.4.min.js"></script>
<script src="../../static/js/plugins/beautifyhtml/beautifyhtml.js"></script>
<script src="../../static/js/content.min.js?v=1.0.0"></script>
<script src="../../static/js/plugins/validate/jquery.validate.min.js"></script>
<script src="../../static/js/plugins/validate/messages_zh.min.js"></script>
<script src="../../static/js/demo/form-validate-demo.js"></script>
<script src="../../static/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="../../static/js/plugins/footable/footable.all.min.js"></script>
<script type="text/javascript" src="../../static/js/plugins/markdown/markdown.js"></script>
<script type="text/javascript" src="../../static/js/plugins/markdown/to-markdown.js"></script>
<script type="text/javascript" src="../../static/js/plugins/markdown/bootstrap-markdown.js"></script>
<script type="text/javascript" src="../../static/js/plugins/markdown/bootstrap-markdown.zh.js"></script>
<script>

    function readTime(time) {
        $("#searchText").val(time);
    }

    $(document).ready(function () {
        $('#loading').hide();
        var updateDateTimeJson = sessionStorage.getItem("updateDateTime");
        if (updateDateTimeJson != null) {
            var temp = eval('(' + updateDateTimeJson + ')');
            var updateDateTime = temp.updateDateTime;
            var numbers = $("#option").find("option");
            for (var j = 1; j < numbers.length; j++) {
                if ($(numbers[j]).val() == "updateDateTime") {
                    $(numbers[j]).attr("selected", "selected");
                }
            }
            $("#searchText").val(updateDateTime);
        }
        setup_draggable();
        $("#n-columns").on("change", function () {
            var v = $(this).val();
            if (v === "1") {
                var $col = $(".form-body .col-md-12").toggle(true);
                $(".form-body .col-md-6 .draggable").each(function (i, el) {
                    $(this).remove().appendTo($col)
                });
                $(".form-body .col-md-6").toggle(false)
            } else {
                var $col = $(".form-body .col-md-6").toggle(true);
                $(".form-body .col-md-12 .draggable").each(function (i, el) {
                    $(this).remove().appendTo(i % 2 ? $col[1] : $col[0])
                });
                $(".form-body .col-md-12").toggle(false)
            }
        });
        $("#copy-to-clipboard").on("click", function () {
            var $copy = $(".form-body").clone().appendTo(document.body);
            $copy.find(".tools, :hidden").remove();
            $.each(["draggable", "droppable", "sortable", "dropped", "ui-sortable", "ui-draggable", "ui-droppable", "form-body"], function (i, c) {
                $copy.find("." + c).removeClass(c).removeAttr("style")
            });
            var html = html_beautify($copy.html());
            $copy.remove();
            $modal = get_modal(html).modal("show");
            $modal.find(".btn").remove();
            $modal.find(".modal-title").html("复制HTML代码");
            $modal.find(":input:first").select().focus();
            return false
        })
    });
    var setup_draggable = function () {
        $(".draggable").draggable({appendTo: "body", helper: "clone"});
        $(".droppable").droppable({
            accept: ".draggable",
            helper: "clone",
            hoverClass: "droppable-active",
            drop: function (event, ui) {
                $(".empty-form").remove();
                var $orig = $(ui.draggable);
                if (!$(ui.draggable).hasClass("dropped")) {
                    var $el = $orig.clone().addClass("dropped").css({
                        "position": "static",
                        "left": null,
                        "right": null
                    }).appendTo(this);
                    var id = $orig.find(":input").attr("id");
                    if (id) {
                        id = id.split("-").slice(0, -1).join("-") + "-" + (parseInt(id.split("-").slice(-1)[0]) + 1);
                        $orig.find(":input").attr("id", id);
                        $orig.find("label").attr("for", id)
                    }
                    $('<p class="tools col-sm-12 col-sm-offset-3">						<a class="edit-link">编辑HTML<a> | 						<a class="remove-link">移除</a></p>').appendTo($el)
                } else {
                    if ($(this)[0] != $orig.parent()[0]) {
                        var $el = $orig.clone().css({"position": "static", "left": null, "right": null}).appendTo(this);
                        $orig.remove()
                    }
                }
            }
        }).sortable()
    };
    var get_modal = function (content) {
        var modal = $('<div class="modal" style="overflow: auto;" tabindex="-1">	<div class="modal-dialog"><div class="modal-content"><div class="modal-header"><a type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</a><h4 class="modal-title">编辑HTML</h4></div><div class="modal-body ui-front">	<textarea class="form-control" 	style="min-height: 200px; margin-bottom: 10px;font-family: Monaco, Fixed">' + content + '</textarea><button class="btn btn-success">更新HTML</button></div>				</div></div></div>').appendTo(document.body);
        return modal
    };
    $(document).on("click", ".edit-link", function (ev) {
        var $el = $(this).parent().parent();
        var $el_copy = $el.clone();
        var $edit_btn = $el_copy.find(".edit-link").parent().remove();
        var $modal = get_modal(html_beautify($el_copy.html())).modal("show");
        $modal.find(":input:first").focus();
        $modal.find(".btn-success").click(function (ev2) {
            var html = $modal.find("textarea").val();
            if (!html) {
                $el.remove()
            } else {
                $el.html(html);
                $edit_btn.appendTo($el)
            }
            $modal.modal("hide");
            return false
        })
    });
    $(document).on("click", ".remove-link", function (ev) {
        $(this).parent().parent().remove()
    });
</script>
<script type="text/javascript">
    $(function () {


        $("#subimt3").click(function () {
            var $options = $("select option:selected");
            var optionselect;//选择的列表
            var searchText = $("#searchText").val();
            if ($options.length != 0) {
                optionselect = $options[0].value;
            }
            window.open("interfaceTestPatient?" + optionselect + "=" + searchText);
        });
        //下拉列表提示联动
        $('#option').change(function () {
            var $options = $("select option:selected");
            var optionselect;//选择的列表
            if ($options.length != 0) {
                optionselect = $options[0].value;
            }
            if (optionselect == "updateDateTime") {
                $('#searchText').attr("placeholder", "样式：2020-02-03");
            } else {
                $('#searchText').attr("placeholder", "样式：20-05648");
            }
        });
        //设置清空按钮相应事件
        $('#clear1').click(function () {
            $('#searchText').val("");
            $('#toastrOptions').html("");
            $('#toastrOptions2').html("");
            $('#submitName').val("");
        });
        $('#clear2').click(function () {
            $('#toastrOptions').html("");
        });
        $('#clear3').click(function () {
            $('#toastrOptions2').html("");
        });
        $('#submitSave').click(function () {
            $('#submitName').val("submitSave");
        });
        $("#inputForm").validate(
            {
                rules: {searchText: "required"},
                submitHandler: function () {
                    var searchText = $("#searchText").val();
                    if (searchText == "" || searchText.length == 0) {
                        return false;
                    } else {
                        if ($('#submitName').val()=="submitSave"){
                            $('#submitName').val("");
                            swal({
                                title: "您确定要保存数据到数据库吗",
                                text: "数据保存后不可撤销！",
                                type: "warning",
                                showCancelButton: true,
                                confirmButtonColor: "#1ab394",
                                confirmButtonText: "保存",
                                cancelButtonText: "取消",
                                closeOnConfirm: false,
                                closeOnCancel: true,
                            }, function () {
                                var $options = $("select option:selected");
                                var optionselect;//选择的列表
                                var searchText = $("#searchText").val();
                                if ($options.length != 0) {
                                    optionselect = $options[0].value;
                                }
                                $.ajax({
                                    type: "GET",
                                    url: "/hetaoInterface/pullWalnutData/" + searchText + "/" + searchText,
                                    dataType: 'json',
                                    contentType: "application/json; charset=UTF-8",
                                    beforeSend: function (XMLHttpRequest) {
                                        XMLHttpRequest.setRequestHeader("Authorization", handleLocalStorage('get', 'Authorization'));
                                        $('#loading').show();
                                        $('#toastrOptions2').html("");
                                        swal("正在获取数据，请稍等........", "获取数据", "warning");
                                    },
                                    success: function (data) {
                                        if (data.code == 200) {
                                            swal("数据保存成功！", data.msg, "success");
                                            $('#loading').hide();
                                            var text = data;
                                            var result = JSON.stringify(text, null, 2);//将字符串转换成json对象
                                            document.getElementById('toastrOptions2').innerText = result;
                                        } else {
                                            swal("数据保存失败！", data.msg, "error");
                                            $('#loading').hide();
                                            var text = data;
                                            var result = JSON.stringify(text, null, 2);//将字符串转换成json对象
                                            document.getElementById('toastrOptions2').innerText = result;
                                        }
                                    }
                                });
                            });
                        }else{
                            fun();
                        }
                    }
                }
            });
    });

    function fun() {
        var $options = $("select option:selected");
        var optionselect;//选择的列表
        var searchText = $("#searchText").val();
        if ($options.length != 0) {
            optionselect = $options[0].value;
            var text = '{"' + optionselect + '":"' + searchText + '"}';
            var test = eval("(" + text + ")");
            var result = JSON.stringify(test, null, 2);
            document.getElementById('toastrOptions').innerText = result;
        }
        if (optionselect == "updateDateTime") {
            style = "visibility: none;"
            $.ajax({
                type: "POST",
                url: '/hetaoInterface/pullWalnutData',
                data: {"updateDateTime": searchText},
                dataType: 'json',
                beforeSend: function (XMLHttpRequest) {
                    XMLHttpRequest.setRequestHeader("Authorization", handleLocalStorage('get', 'Authorization'));
                    $('#loading').show();
                    $('#toastrOptions2').html("");
                },
                success: function (data) {
                    $('#loading').hide();
                    var text = data;
                    var result = JSON.stringify(text, null, 2);//将字符串转换成json对象
                    document.getElementById('toastrOptions2').innerText = result;
                }
            });
        } else {
            $.ajax({
                type: "POST",
                url: '/langjiaInterface/interfaceTestPatient',
                data: {"pathNo": searchText},
                dataType: 'json',
                beforeSend: function (XMLHttpRequest) {
                    XMLHttpRequest.setRequestHeader("Authorization", handleLocalStorage('get', 'Authorization'));
                },
                success: function (data) {
                    var text = data;
                    var result = JSON.stringify(text, null, 2);//将字符串转换成json对象
                    document.getElementById('toastrOptions2').innerText = result;
                },
                error: function () {
                    alert("取数失败！");
                }
            });
        }
    }
</script>
</body>
</html>
